package puf.m2.regular;

import java.util.List;



public class NormalRegToTileRegConverter {
	public String convertToTileGrexp (String normalRegexp){
		//replace a=(1,~a,1) ;~a=(a,~a,a)
		
		char[] regexp= normalRegexp.toCharArray();
		String result="";
		char tmp,tmp1;
		for(int i=0;i<regexp.length;i++){
			if(regexp[i]=='(')
				result+=regexp[i];
			else if(regexp[i]==')')
				result+=regexp[i];
			else if(regexp[i]=='~'){
				tmp=regexp[i+1];
				tmp1=regexp[i+2];
				if(regexp[i+2]=='*' || regexp[i+2]=='+' )
					result+="("+tmp+",~"+tmp+","+tmp+")"+tmp1;
				else
					result+="("+tmp+",~"+tmp+","+tmp+")";
			}
			else {
				tmp=regexp[i];
				tmp1=regexp[i+1];
				if(regexp[i+2]=='*' || regexp[i+2]=='+' )
					result+="(1"+",~"+tmp+",1)"+tmp1;
				else
					result+="(1"+",~"+tmp+",1)";
			}
				
		}
		return result;
	}
}
